package se.sll.itintegration.catalogue.gui.service.view.capacity;

import se.sll.service.catalogue.common.Translator;
import se.sll.service.catalogue.common.rest.model.Product;
import se.sll.service.catalogue.common.rest.model.ProductReference;

/**
 *
 * @author Christer Palm, Nogui
 */
public class ProductReferenceTranslator implements Translator<ProductReference, CapacityViewProduct> {
    private static final ProductReferenceTranslator INSTANCE = new ProductReferenceTranslator();

    private ProductReferenceTranslator() {
    }

    @Override
    public CapacityViewProduct translate(ProductReference from) {
        return translateTo(from, new CapacityViewProduct());
    }

    @Override
    public CapacityViewProduct translateTo(ProductReference from, CapacityViewProduct to) {
        Product srcProduct = from.getProduct();
        to.setId(srcProduct.getName());
        to.setName(srcProduct.getDisplayName());
        return to;
    }

    public static ProductReferenceTranslator getInstance() {
        return INSTANCE;
    }
}
